extends CanvasLayer

onready var rect: TextureRect = $TextureRect
onready var label: Label = $Label

var progress: float = 0.0 setget set_progress, get_progress

var max_texture_size_x = 20480
var min_label_x = -32
var max_label_x = 992

func set_progress(value: float):
	var rate = get_viewport().get_visible_rect().size.x / 1024
	
	rect.rect_size.x = max_texture_size_x * value * rate
	label.rect_position.x = min_label_x + (max_label_x - min_label_x) * value * rate
	
	label.text = str(int(value * 100)) + '%'
	progress = value
	
func get_progress():
	return progress

# func _process(delta: float) -> void:
	# print(progress)
#	set_progress(progress+delta)
